public class Solution2293 {
    public int minMaxGame(int[] nums) {
        while (nums.length>1){
            int[] p=new int[nums.length/2];
            for (int i=0;i<p.length;i++){
                if (i%2==0){
                    p[i]=Math.min(nums[i*2],nums[i*2+1]);
                }else {
                    p[i]=Math.max(nums[i*2],nums[i*2+1]);
                }
            }
            nums=p;
        }
        return nums[0];
    }

    public static void main(String[] args) {
        System.out.println(new Solution2293().minMaxGame(new int[]{1,3,5,2,4,8,2,2}));
    }
}
